<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ page import="com.gouwudai.gobbs.pojo.TbbsClass" %>
<%@ taglib uri="/tld/extremecomponents" prefix="ec" %>
<%@ include file="../common/common.jsp" %>	
<%@ include file="user_pass2.jsp" %>
<%
int classId = ParamUtils.getIntParameter(request, "classId", 0);

IClassService classService = (IClassService)BeanManager.getBean("classService");
TbbsClass currentClass = null;
/***************** 权限管理模块 START *********************/
//判断当前版面是否存在
try
{
	currentClass = classService.load(new Integer(classId));
}
catch(Exception e)
{
	HtmlConst.errors(out,7,"您浏览的版面不存在或已被删除！");
	return;
}
//判断用户类型 START
IClassUserService classUserService = (IClassUserService)BeanManager.getBean("classUserService");
int operatorType = 0;//当前用户的类型，-1：游客，0：普通，1:发帖人，2：版主
if(classUserService.isClassManager(new Integer(classId),USER_ID))	//验证用户是否为版主
{
	operatorType = 2;
}
//判断用户类型 END
if(operatorType<2)
{
	HtmlConst.errors(out,1,"您不是该版的版主，没有当前操作的权限！");
	return;
}

userLogin.hasClassPermission(classId,4002);//公告管理权限
/***************** 权限管理模块 END *********************/
String className = currentClass.getClassName();
//目前支持3级栏目
Integer parentId = currentClass.getParentId();//父栏目ID，如果不为空则说明有父栏目
String parentName = "";
TbbsClass parentClass = null;
Integer grandId = null;//二级父栏目ID，如果不为空则说明有父栏目
String grandName = "";
TbbsClass grandIdClass = null;
if(parentId!=null&&parentId.intValue()>0)
{
	parentClass = classService.load(parentId);	
	parentName = parentClass.getClassName();
	grandId = parentClass.getParentId();
}
if(grandId!=null&&grandId.intValue()>0)
{
	grandIdClass = classService.load(grandId);	
	grandName = grandIdClass.getClassName();
}

StringBuilder totalClassName = new StringBuilder(50);//栏目全名，包括父栏目
if(grandId!=null&&grandId.intValue()>0)
{
	totalClassName.append(grandIdClass.getClassName());
	totalClassName.append(" - ");
}
if(parentId!=null&&parentId.intValue()>0)
{
	totalClassName.append(parentClass.getClassName());
	totalClassName.append(" - ");
}
totalClassName.append(currentClass.getClassName());

IAfficheService afficheService = (IAfficheService)BeanManager.getBean("afficheService");
afficheService.listByPage(request);
%>

<html>
<head>
<title><%=SYSTITLE%> - <%=totalClassName.toString() %> - 公告信息管理</title>
<%@ include file="../common/meta.inc" %>
<link href="css/defaultStyle.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/extremetable/extremecomponents.css"/>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/common-validator.js"></script>
<script language="javascript" type="text/javascript" src="scripts/showMenu.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/prototype.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/buffalo/buffalo.js"></script>
<script language="javascript">
var END_POINT="${pageContext.request.contextPath}/buffalo";
var buffalo = new Buffalo(END_POINT);

function newInfo()
{	
	location = "class_manage_affiche_new.jsp?classId=<%=classId%>";
}

function updateInfo(id)
{
	location = "class_manage_affiche_update.jsp?classId=<%=classId%>&affId="+id;
}

function deleteInfo(objs)
{
	if(!sl_confirmRemove(objs))
		return;	

	var ids = getCheckBoxValues(objs);
	buffalo.remoteCall("afficheServiceAjaxService.delete",[ids], function(reply) {
        ajaxSubmit(reply.getResult(),"删除成功！","reload");        
    });
	
}
</script>
</head>
<body leftMargin=5 topMargin=10 rightmargin="0" bottommargin="0" >
<%@ include file="../common/waiting.inc" %>
<SCRIPT language="javascript">

setStatus('<%=SYSTITLE%> - <%=totalClassName.toString() %> - 公告列表');
</SCRIPT>
<script language="javascript" type="text/javascript" src="template/scripts/topBar.js"></script>
<DIV class="line"></DIV>
<DIV class="list_table_0">
	<%=HtmlConst.navMenu(HtmlConst.navClassMenu(new Integer(classId),parentId,grandId,className,parentName,grandName ))%>&gt;&gt;公告列表
</DIV>
<DIV class="line"></DIV>
<jsp:include flush="true" page="includes/class_manage_menu.jsp?classId=<%=classId %>"></jsp:include>
<form name="theform" method="post" action="class_manage_affiche.jsp">
	<ec:table 
		items="resultList"
		var="rs"	
		retrieveRowsCallback="limit"
        sortRowsCallback="limit"			
		action="${pageContext.request.contextPath}/club/class_manage_affiche.jsp"		
		
		>	
		<ec:parameter name="classId" value="<%=classId %>"/>	
		<ec:row>
				<ec:column property="AFF_ID" title="序号" >
					<input type="checkbox" name="affId" value="${rs.AFF_ID}">${rs.AFF_ID}
				</ec:column>			
				<ec:column property="TITLE" title="公告主题" />
				<ec:column property="VALID_DAYS" title="有效期">
				${rs.VALID_DAYS}天
				</ec:column>				
				<ec:column property="OP_USER" title="发布人" />
				<ec:column property="CREATE_DATETIME" title="发布时间" />
				<ec:column property="1" title="操作" width="5%" sortable="false" viewsAllowed="html">
					<input type="button" name="btnEdit" value="编辑" onclick="javascript:updateInfo(${rs.AFF_ID})">
				</ec:column>
		</ec:row>
	</ec:table>
</form>		
			<table border="0" width="100%">
				<tr valign="top">
					<td align="right">
					<button class="btn" accessKey=n id="btnNew" name="btnNew" title="新建记录" onclick="javascript:newInfo();">新建(<u>N</u>)</button>
					&nbsp;&nbsp;&nbsp; 
					<%if(userLogin.withClassPermission(classId,4003)) { %>
					<button class="btn" accessKey=n id="btnDelete" name="btnDelete" title="删除记录" onclick="javascript:deleteInfo(document.theform.affId);">删除(<u>D</u>)</button>
					&nbsp;&nbsp;&nbsp;
					<%} %>
					<button class="btn" accessKey=r id="btnRefresh" name="btnRefresh" title="刷新当前页面" onclick="javascript:location.reload();this.disabled=true;">刷新(<u>R</u>)</button>
					&nbsp;&nbsp;&nbsp;<td>
				</tr>
			</table>	
<%=COPYRIGHTFOOT%>		
<%@ include file="../common/foot.inc"%>	
</body>
</html>
